package com.wb.spring.boot.autoconfigure;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;

/**
 * @Author deeprado
 * @Date 2022/9/13 16:39
 */
@ConfigurationProperties(prefix = "wb")
public class WbProperties {

    public static final String PREFIX = "wb";


    /**
     * 是否启用
     */
    private boolean enabled;

    /**
     * 要检查的包路径
     */
    private String packageScan;

    /**
     * 服务名称
     */
    @Value("${wb.name:${spring.application.name:}}")
    private String name;


    /**
     * 注册中心类型
     */
    private String registerType;

    /**
     * http client类型
     */
    private String loadType;

    /**
     * http client类型
     */
    private String httpType;

    /**
     * http 异步
     */
    private boolean async = false;

    /**
     * http 重试次数
     */
    private int maxAttempts = 0;

    /**
     * redis注册信息
     */
    private RedisRegister redisRegister;
    private ConsulRegister consulRegister;

    public static class RedisRegister {
        /**
         * redis地址
         */
        private String host;

        /**
         * 端口
         */
        private int port;

        /**
         * 密码
         */
        private String password;

        public String getHost() {
            return host;
        }

        public void setHost(String host) {
            this.host = host;
        }

        public int getPort() {
            return port;
        }

        public void setPort(int port) {
            this.port = port;
        }

        public String getPassword() {
            return password;
        }

        public void setPassword(String password) {
            this.password = password;
        }
    }


    public static class ConsulRegister {
        /**
         * redis地址
         */
        private String host;

        /**
         * 端口
         */
        private int port;

        /**
         * 密码
         */
        private String password;

        public String getHost() {
            return host;
        }

        public void setHost(String host) {
            this.host = host;
        }

        public int getPort() {
            return port;
        }

        public void setPort(int port) {
            this.port = port;
        }

        public String getPassword() {
            return password;
        }

        public void setPassword(String password) {
            this.password = password;
        }
    }

    public boolean isEnabled() {
        return enabled;
    }

    public void setEnabled(boolean enabled) {
        this.enabled = enabled;
    }

    public String getPackageScan() {
        return packageScan;
    }

    public void setPackageScan(String packageScan) {
        this.packageScan = packageScan;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public RedisRegister getRedisRegister() {
        return redisRegister;
    }

    public void setRedisRegister(RedisRegister redisRegister) {
        this.redisRegister = redisRegister;
    }

    public ConsulRegister getConsulRegister() {
        return consulRegister;
    }

    public void setConsulRegister(ConsulRegister consulRegister) {
        this.consulRegister = consulRegister;
    }

    public String getRegisterType() {
        return registerType;
    }

    public void setRegisterType(String registerType) {
        this.registerType = registerType;
    }

    public String getLoadType() {
        return loadType;
    }

    public void setLoadType(String loadType) {
        this.loadType = loadType;
    }

    public String getHttpType() {
        return httpType;
    }

    public void setHttpType(String httpType) {
        this.httpType = httpType;
    }

    public boolean isAsync() {
        return async;
    }

    public void setAsync(boolean async) {
        this.async = async;
    }

    public int getMaxAttempts() {
        return maxAttempts;
    }

    public void setMaxAttempts(int maxAttempts) {
        this.maxAttempts = maxAttempts;
    }
}
